home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_03_06
/
3n06052a
< prev
next >
Wrap
Text File
|
1992-02-02
|
544b
|
35 lines
Listing 1
#include <stdio.h>
typedef int T;
/*
* Tcmp - compare two arrays of integers
*/
int Tcmp(const T *a1, const T *a2, size_t n)
{
int cmp;
size_t i;
for (i = 0; i < n; ++i)
if ((cmp = a1[i] - a2[i]) != 0)
return cmp;
return 0;
}
/*
* Sample calls to Tcmp...
*/
int a[] = {1, 2, 3, 4, -5};
int b[] = {1, 2, 3, 4, 4};
int main(void)
{
printf("a vs. b = %d\n", Tcmp(a, b, 4));
printf("a vs. b = %d\n", Tcmp(a, b, 5));
return 0;
}